package com.xiyin.controller;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.xiyin.entity.User;
import com.xiyin.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xukaihang
 * @since 2024-08-29
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserService userService;
    //新增
    @PostMapping("/add")
    @DS("slave_1")
    public ResponseEntity<User> save(@RequestBody User user1) {
        boolean save = userService.save(user1);
        return ResponseEntity.ok(save ? user1 : null);
    }
}
